import router from "./router";
import { useToken } from "./stores/token";

const whiteList: string[] = ["/login", "/404"]
router.beforeEach((to, from, next) => {
    const store = useToken()
    if (store.getToken()) {
        if (to.path === "/login") {
            next("/")
        } else {
            next()
        }
    } else {
        if (whiteList.includes(to.path)) {
            next()
        } else {
            next("/login")
        }
    }
})